import fetch from "common/src/utils/fetch";
import UTILS from "common/src/utils/utils";

/**
 * 新增未选课原因
 */
function addNoSelectReason(data) {
  return fetch({
    url: "/api/electionservice/reportManagement/addNoSelectReason",
    method: "post",
    data: data
  });
}

/**
 *
 * 导出未选课学生名单
 */
function exportStudents(data) {
  return fetch({
    url: "/api/electionservice/reportManagement/export",
    method: "post",
    data: data
  });
}

/**
 *
 * 研究生导出未选课学生名单
 */
function graduareExportStudents(data) {
  return fetch({
    url:
      "/api/electionservice/reportManagement/exportStudentNoCourseListGradute",
    method: "post",
    data: data,
    responseType: "blob"
  }).then(res => {
    UTILS.downloadFile(
      res,
      "WeiXuanKeXueShengMingDanExport.xls",
      "application/vnd.ms-excel;charset=utf-8"
    );
  });
}
/**
 *
 * 查询是否导出完成未选课学生名单
 */
function exportStatus(key) {
  return fetch({
    url: "/api/electionservice/reportManagement/result/" + key,
    method: "get"
  });
}

/**
 *
 * 查看教材
 */
function detailTextbook(data) {
  return fetch({
    url: "api/textbookservice/teachingTextbook/books",
    method: "post",
    data: data
  });
}


/**
 *
 * 重修选课统计导出
 */
function exportRetakeElecStatistics(data) {
  return fetch({
    url: "/api/electionservice/retakeCourse/exportRetakeElecStatistics",
    method: "post",
    data: data
  });
}

/**
 *
 * 查询是否导出完成重修选课名单
 */
function exportRebuildStatus(key) {
  return fetch({
    url: "/api/electionservice/retakeCourse/result/" + key,
    method: "get"
  });
}

/**
 *
 * 导出
 */
function exportTextbook(data) {
  return fetch({
    url: "api/textbookservice/teachingTextbook/books/excel",
    method: "post",
    data: data,
    responseType: "blob"
  }).then(res => {
    UTILS.downloadFile(
      res,
      "textbook.xls",
      "application/vnd.ms-excel;charset=utf-8"
    );
  });
}

export default {
  findElectCourseListUrl:
    "/api/electionservice/reportManagement/findNoSelectCourseList",
  findRetakeElecStatisticsUrl:
    "/api/electionservice/retakeCourse/retakeElecStatistics",
  addNoSelectReason: addNoSelectReason,
  exportStudents: exportStudents,
  exportStatus: exportStatus,
  graduareExportStudents: graduareExportStudents,
  detailTextbook: detailTextbook,
  exportTextbook: exportTextbook,
  exportRetakeElecStatistics: exportRetakeElecStatistics,
  exportRebuildStatus: exportRebuildStatus
};
